package org.formal.system.service.impl;

import java.util.Arrays;
import java.util.List;

import org.formal.common.service.BaseServiceImpl;
import org.formal.common.utils.DateUtils;
import org.formal.system.dao.RoleDao;
import org.formal.system.dao.RoleResourceDao;
import org.formal.system.entity.RoleEntity;
import org.formal.system.entity.RoleResourceEntity;
import org.formal.system.service.RoleService;
import org.formal.system.shiro.manager.TokenManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria;

/**
 * 角色实现类
 * @author jiangyan
 *
 */
@Service
public class RoleServiceImpl extends BaseServiceImpl<RoleEntity> implements RoleService{
	
	@Autowired
	private RoleDao roleDao;
	
	@Autowired 
	private RoleResourceDao roleResourceDao;
	/**
	 * 根据用户id获取角色集
	 */
	@Override
	public List<RoleEntity> getRoleByUserId(String userId) {
		return roleDao.getRoleByUserId(userId);
	}
	/**
	 * 根据用户id获取角色id集
	 */
	@Override
	public String getRoleIdsByUserId(String userId) {
		return roleDao.getRoleIdsByUserId(userId);
	}
	/**
	 * 根据资源id获取角色集合
	 */
	@Override
	public List<RoleEntity> getRolesByResourceId(String resourceId) {
		return roleDao.getRolesByResourceId(resourceId);
	}
	/**
	 * 根据资源id获取角色ids字符串
	 */
	@Override
	public String getRoleIdsByResourceId(String resourceId) {
		return roleDao.getRoleIdsByResourceId(resourceId);
	}

	@Override
	public void saveRoleRelation(String resourceId, String[] roleArray) {

	}
	
}
